package com.scdt.china.shorturl.common;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import com.scdt.china.shorturl.pojo.Url;

import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: zhouchao
 * @Date: 2021/11/26 12:35
 * @Description:
 */
public interface Constants {
    /**
     * 保存短链接的map
     */
    Map<String, Url> URL_MAP = new ConcurrentHashMap<>();

    /**
     * 链接的布隆过滤器，用短链接获取长链接时判断用,TOTAL大小可根据实际情况而定
     */
    int TOTAL = 1000000;
    BloomFilter<String> URL_BLOOM_FILTER = BloomFilter.create(Funnels.stringFunnel(Charset.defaultCharset()), TOTAL);
}
